JavaScript

{grid.object}gridLink Method

Syntax

{grid.Object}.gridLink(linkDefinition [,filterDefinition [, orderDefinition]])

Arguments

linkDefinitionstring

Defines the link to be used.

filterDefinitionstring

Default = 'Null'. An expression used to filter the records.

orderDefinitionstring

Default = 'Null'. An expression used to order (sort) the records. If the Grid is based on DBF files, use Xbasic syntax for the expression. If the Grid is based on a SQL data source, use SQL syntax for the expression.

Description

Linking a Grid is similar to filtering a Grid, except that when the linked Grid is edited, or new rows are entered, the linking field values are automatically set to the linking values.

Discussion

For example if a Grid is linked using the link definition of Customer_Id=00023 then the Grid will only show records in which the Customer_id is equal to '00023' and any new records that are added will automatically set the Customer_id to '00023'. The link definition is specified using a special syntax. You can also specify an optional filter expression and order expression. The filter is applied in addition to the filter implied by the link definition.

//Link the Grid on the 'firstname' and 'lastname' fields. firstname value is 'Sam' and 'lastname' value is
'Jones'. Both fields are character fields.
{grid.Object}.gridLink('firstname(C:Sam),lastname(C:Jones)');

//Link the Grid on the Customer_id field. Customer_id value of 123 (a numeric value)
{grid.Object}.gridLink('customer_id(N:123)');

//Link the Grid on the Customer_id field and also filter to only show orders above $1,000
{grid.Object}.gridLink('customer_id(N:123)','orderTotal>1000');

//Link the Grid on the Customer_id field and order by descending OrderDate:
{grid.object}.gridLink('customer_id(N:123)','','orderDate DESC');
If the Grid is based on .dbf files, use Xbasic syntax for the filter. If the Grid is based on SQL tables, use SQL syntax for the filter.

See Also